package com.example.myapp;

import android.app.Activity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

public class MyActivity extends Activity {


    private ListView mListView;

    private List<String> mList;


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        mList = new ArrayList<>();
        for (int i = 0; i < 2; i++) {
            mList.add("this is " + i);
        }

        mListView = (ListView) findViewById(R.id.listview);

        mListView.setAdapter(new BaseAdapter() {
            @Override
            public int getCount() {
                return mList.size();
            }

            @Override
            public Object getItem(int i) {
                return mList.get(i);
            }

            @Override
            public long getItemId(int i) {
                return i;
            }

            @Override
            public View getView(int i, View view, ViewGroup viewGroup) {
                TextView textView = (TextView) LayoutInflater.from(MyActivity.this).inflate(android.R.layout.simple_list_item_1, null);
                textView.setText(mList.get(i));
                return textView;
            }
        });


    }
}
